<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>我发出的消息</title>
	<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0">
	<script src="__PUBLIC__/News/js/jweixin-1.1.0.js"></script>
	<link rel="stylesheet" href="__PUBLIC__/News/css/weui.min.css"/>
    <link rel="stylesheet" href="__PUBLIC__/News/css/example.css"/>
	<script src="__PUBLIC__/News/js/jquery.js"></script>
	<script>
		wx.config({
			//关闭调试模式
		    debug: false,
		    appId: '<?php echo $signPackage["appId"];?>',
		    timestamp: <?php echo $signPackage["timestamp"];?>,
		    nonceStr: '<?php echo $signPackage["nonceStr"];?>',
		    signature: '<?php echo $signPackage["signature"];?>',
		    jsApiList: [
		      // 所有要调用的 API 都要加到这个列表中
		      'closeWindow','hideOptionMenu'
		    ]
	    });
	    //屏蔽菜单
	    wx.ready(function(){
 			//屏蔽菜单
 			wx.hideOptionMenu();
		});
		function close_window(){
			wx.closeWindow();
		}
	</script>
	<script>
		//删除标记
		var del_state = 0;
		var temp_newsid = '';
		$(function(){
			//监听点击查看详情
			$('.show_msg_info').bind('click',function(){
				var newsid = $(this).attr('newsid');
				location.href = "__CONTROLLER__/getCount/newsid/"+newsid+'/state/{$corpid}';
			});
			//关闭事件监听
			$('#msg_close').bind('click',function(){
				close_window();
			});
			//清除指定消息
			$('.del_msg').bind('click',function(){
				del_state = 0;
				temp_newsid = $(this).attr('newsid');
				$('#dialog_cont').html('确定要删除该回执消息吗?');
				$('#dialog1').show();
			});
			//清除全部消息
			$('#del_all').bind('click',function(){
				del_state = 1;
				$('#dialog_cont').html('确定要清空所有回执消息记录吗?');
				$('#dialog1').show();
			});
			$('#del_no').bind('click',function(){
				$('#dialog1').hide();
			});
			
			
			$('#del_yes').bind('click',function(){
				//执行删除操作
				//判断删除标记
				if(del_state==0){
					//删除单条记录
					var url = "__CONTROLLER__/del_single/state/{$corpid}/newsid/"+temp_newsid;
				}else{
					//删除所有记录
					var url = "__CONTROLLER__/deleteAll/state/{$corpid}/userid/{$userid}";
				}
				location.href = url;
			});
			//预加载通讯录成员头像数据
			$.post('__MODULE__/Cache/loadPersonImage/state/{$corpid}',function(res){
				var cache_html = '';
				$(res).each(function(){
					cache_html += "<img src='"+$(this)[0].avatar+"' width=1>";
				});
				$('#person_image_cache').html(cache_html);
			});
		});
	</script>
</head>
<body>	
	 <!--提示信息开始-->
	<div id="dialog1" style="display:none;">
	<div class="weui-mask"></div>
		<div class="weui-dialog">
			<div class="weui-dialog__hd"><strong class="weui-dialog__title">操作提示</strong></div>
			<div class="weui-dialog__bd" id="dialog_cont">
			</div>
			<div class="weui-dialog__ft">
			<a href="javascript:;" id="del_no" class="weui-dialog__btn weui-dialog__btn_default">取消</a>
			<a href="javascript:;" id="del_yes" class="weui-dialog__btn weui-dialog__btn_primary">确定</a>
			</div>
		</div>
	</div>
	<!--循环消息开始-->
	<?php if(!count($news_list)):?>
		<div class="page__bd page__bd_spacing" style="text-align:center;padding:20px;font-size: 4vw;margin-top:10%;">
			<i class="weui-icon-info weui-icon_msg"></i>
			<div style="margin-top:7%;text-align: center;font-size: 4vw;">暂无推送消息记录!</div>
    	</div>
	<?php else:?>
		<div class="weui-cells__title">以下消息按时间倒序排序 共计<?php echo count($news_list);?>条消息</div>		
	<?php endif;?>
	<?php foreach($news_list as $k => $v):?>
	<div class="weui-form-preview">
        <div class="weui-form-preview__hd">
            <label class="weui-form-preview__label">消息标题</label>
            <em class="weui-form-preview__value" style="font-size: 4vw;"><?php echo mb_substr($v['title'],0,10,'utf-8');?></em>
        </div>
        <div class="weui-form-preview__bd">
            <div class="weui-form-preview__item">
                <label class="weui-form-preview__label">回执进度</label>
                <span class="weui-form-preview__value">
                	<div class="weui-progress">
			            <div class="weui-progress__bar">
			                <div class="weui-progress__inner-bar js_progress" style="width: <?php echo $v['avg'];?>%;"></div>
			            </div>
			                &nbsp;<?php echo $v['avg'];?>%
		       		</div>
                </span>
            </div>
            <div class="weui-form-preview__item">
                <label class="weui-form-preview__label">推送时间</label>
                <span class="weui-form-preview__value"><?php echo date('m月d日 H:i:s',$v['time'])?></span>
            </div>
        </div>
        <div class="weui-form-preview__ft">
            <a class="weui-form-preview__btn weui-form-preview__btn_default show_msg_info" 
            	href="javascript:" newsid="<?php echo $v['newsid'];?>">查看详情</a>
            <a newsid="<?php echo $v['newsid'];?>" class="weui-form-preview__btn weui-form-preview__btn_default del_msg" style="color:red;" href="javascript:">删除记录</a>
        </div>
    </div>
    <br/>
    <?php endforeach;?>
    <!--循环消息结束-->
    <?php if(!count($news_list)):?>
    	<div class="page__bd page__bd_spacing">
	    	<a id="msg_close" href="javascript:;" class="weui-btn weui-btn_plain-primary">返回</a>
    	</div>
	<?php else:?>
    <div class="page__bd page__bd_spacing">
    	<a id="del_all" href="javascript:;" class="weui-btn weui-btn_warn">全部清除</a>
    	<a id="msg_close" href="javascript:;" class="weui-btn weui-btn_plain-primary">关闭</a>
    </div>
    <?php endif;?>
    <div class="weui-footer" style="margin-top:10%;">
        <p class="weui-footer__links">
            <a href="javascript:void(0);" class="weui-footer__link">中国航天 | 神舟软件</a>
        </p>
        <p class="weui-footer__text">Copyright &copy; 2003-2017</p>
    </div>
    <div style="display: none;" id="person_image_cache"></div>
</body>
</html>